unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, rtcInfo, rtcConn, rtcTcpCli, StdCtrls;

type
  TForm1 = class(TForm)
    Btnx_1: TButton;
    Btnx_2: TButton;
    TcpClient_1: TRtcTcpClient;
    Btnx_3: TButton;
    Btnx_4: TButton;
    Btnx_5: TButton;
    procedure Btnx_1Click(Sender: TObject);
    procedure Btnx_2Click(Sender: TObject);
    procedure Btnx_3Click(Sender: TObject);
    procedure TcpClient_1DataReceived(Sender: TRtcConnection);
    procedure TcpClient_1ConnectError(Sender: TRtcConnection;
      E: Exception);
    procedure TcpClient_1ConnectFail(Sender: TRtcConnection);
    procedure Btnx_4Click(Sender: TObject);
    procedure Btnx_5Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  Class_KzUtils;

{$R *.dfm}

procedure TForm1.Btnx_1Click(Sender: TObject);
var
  StrsA:TStringList;
begin
  StrsA:=TStringList.Create;
  StrsA.LoadFromFile('texta.txt');

  TcpClient_1.ServerAddr:='192.168.0.51';
  TcpClient_1.ServerPort:='1861';
  TcpClient_1.Connect();
  TcpClient_1.Write(StrsA.Text);

  FreeAndNil(StrsA);
end;

procedure TForm1.Btnx_2Click(Sender: TObject);
var
  StrsA:TStringList;
begin
  StrsA:=TStringList.Create;
  StrsA.LoadFromFile('textb.txt');

  TcpClient_1.ServerAddr:='192.168.0.51';
  TcpClient_1.ServerPort:='1861';
  TcpClient_1.Connect();
  TcpClient_1.Write(StrsA.Text);
  ShowMessageFmt('%D',[Length(StrsA.Text)]);

  FreeAndNil(StrsA);
end;

procedure TForm1.Btnx_3Click(Sender: TObject);
begin
  TcpClient_1.ServerAddr:='192.168.0.51';
  TcpClient_1.ServerPort:='8841';
  TcpClient_1.Connect();
  TcpClient_1.Write('<policy-file-request/>');
  //TcpClient_1.Disconnect;
end;

procedure TForm1.TcpClient_1DataReceived(Sender: TRtcConnection);
begin
  ShowMessage(Sender.Read);
end;

procedure TForm1.TcpClient_1ConnectError(Sender: TRtcConnection;
  E: Exception);
begin
  ShowMessage('connecterror');
end;

procedure TForm1.TcpClient_1ConnectFail(Sender: TRtcConnection);
begin
  ShowMessage('connectfail');
end;

procedure TForm1.Btnx_4Click(Sender: TObject);
begin
  WinExec(PChar('net start delphiservice'),SW_NORMAL);
end;

procedure TForm1.Btnx_5Click(Sender: TObject);
begin
  WinExec(PChar('net stop delphiservice'),SW_NORMAL);
end;

end.
